package com.hz.springboot01.config;

import com.hz.springboot01.pojo.Provider;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@Configuration
@PropertySource("classpath:smbms.yml") //读取文件
@ConfigurationProperties(prefix = "student")//前缀
public class SpringbootConfig {
    @Value("${sname}")
    private  String sname;
    @Value("${age}")
    private int age;

    /**
     * 一个创建对象的方法
     * @return
     */
    @Bean //实例化对象  并放入Spring容器
    public Provider newProvider(){
        Provider provider = new Provider();
        provider.setProName(sname);
        return provider;
    };

}
